<template>
  <div class="code-layout">
    <!-- <div class="code-materials">
      <md-preview :biz_id="id" :type="type" :is_public="true" class="preview" v-if="nowRouter.includes('code')" />
      <div class="file" v-if="nowRouter.includes('file')">
        <file-list :biz_id="id" :type="type" :is_public="true" />
      </div>
    </div> -->

    <div class="code-info">
      <div class="code-info-item">
        <h3 class="info-title">基本信息</h3>
        <ul class="info-item">
          <li>
            <span class="key">名称:</span>
            <span class="val">{{ detailData.name }}</span>
          </li>
          <li>
            <span class="key"> 创建人： </span>
            <span class="val">{{
              detailData.create_user && (detailData.create_user.nick_name ||
                detailData.create_user.username)
            }}</span>
          </li>
          <li>
            <span class="key">创建时间： </span>
            <span class="val">{{ detailData.create_time }}</span>
          </li>
        </ul>
      </div>

      <div class="code-info-item">
        <h3 class="info-title">描述信息</h3>
        <md-preview :biz_id="id" :type="type" :is_public="true" class="preview" v-if="nowRouter.includes('code')" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    let typeMap = { '0': 'dataset', '1': 'workspace', '2': 'model' }

    return {
      id: null,
      type: typeMap[this.$route.query.active]
      //  detailData: {}
    };
  },
  props: ['detailData', 'version', 'active', 'nowRouter'],
  async created() {
    this.getData()
  },
  async mounted() {
    this.$nextTick(() => {
      console.log("code-detail", this.detailData)
    })
  },

  destroyed() {

  },
  methods: {
    getData() {
      console.log("active", this.active)
      console.log("version", this.version)
      if (this.active == 0) {
        this.id = this.detailData.source
      }
      if (this.active == 1) {
        this.id = this.version.id
      }
      if (this.active == 2) {
        this.id = this.version.id
      }
      console.log("id", this.id)
    }

  }
}
</script>
<style lang="less" scoped>
@import "~@/assets/css/code.less";
</style>